//
//  XJYRegisterNameTableViewCell.m
//  高仿萝卜书摘
//
//  Created by 谢俊逸 on 2016/11/27.
//  Copyright © 2016年 谢俊逸. All rights reserved.
//

#import "XJYRegisterNameTableViewCell.h"

@implementation XJYRegisterNameTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
#pragma mark Notification
    [_nameTextfield addTarget:self action:@selector(editDidBegin:) forControlEvents:UIControlEventEditingDidBegin];
    [_nameTextfield addTarget:self action:@selector(textValueChanged:) forControlEvents:UIControlEventEditingChanged];
    [_nameTextfield addTarget:self action:@selector(editDidEnd:) forControlEvents:UIControlEventEditingDidEnd];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}


#pragma mark TextField
- (void)editDidBegin:(id)sender {
    if (self.editDidBeginBlock) {
        self.editDidBeginBlock(self.nameTextfield.text);
    }
}

- (void)editDidEnd:(id)sender {
    if (self.editDidEndBlock) {
        //调用这个block  这个block在controller  中执行，实现了传值
        self.editDidEndBlock(self.nameTextfield.text);
    }
}

- (void)textValueChanged:(id)sender {
    if (self.textValueChangedBlock) {
        self.textValueChangedBlock(self.nameTextfield.text);
    }
}
@end
